//
//  ViewController.m
//  Imagegundong
//
//  Created by yb on 16/3/3.
//  Copyright © 2016年 yb. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *imageID;

@property (weak, nonatomic) IBOutlet UIImageView *myImageView;

- (IBAction)shangyizhang;
- (IBAction)xiayizhang;


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)shangyizhang {
    NSString *myImage = self.imageID.text;
    NSString *imageName = [[NSString alloc]init];
    NSString *idofstr =[imageName substringToIndex:2];
    int idofint = [idofstr intValue];
    //
    if (idofint == 1) {
        /*UIAlertView *msg = [[UIAlertView alloc]initWithTitle:@"提示" message:@"已经是第一张了，前面没有图片了" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:,nil];*/
        UIAlertController *myc=[UIAlertController alertControllerWithTitle:@"提示" message:@"已经是第一张了，前面没有图片了" preferredStyle:UIAlertControllerStyleAlert];
        
        [self presentViewController:myc animated:YES completion:nil];
        
    }
    else{
        idofint --;
        if (idofint < 10) {
            idofstr = [NSString stringWithFormat:@"0%d/24",idofint];
        }
        else
        {
            idofstr = [NSString stringWithFormat:@"%d/24",idofint];
            
        }
        imageName = [NSString stringWithFormat:@"%d.jpg",idofint];
        //将文字和图片显示出来
        self.imageID.text = idofstr;
        self.myImageView.image = [UIImage imageNamed:myImage];
    }
    
}

- (IBAction)xiayizhang {
    NSString *myImage = self.imageID.text;
    NSString *imageName = [[NSString alloc]init];
    NSString *idofstr =[imageName substringToIndex:2];
    int idofint = [idofstr intValue];
    //
    if (idofint == 24) {
        /*UIAlertView *msg = [[UIAlertView alloc]initWithTitle:@"提示" message:@"已经是第一张了，前面没有图片了" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:,nil];*/
        UIAlertController *myc=[UIAlertController alertControllerWithTitle:@"提示" message:@"已经是最后一张了，后面没有图片了" preferredStyle:UIAlertControllerStyleAlert];
        
        [self presentViewController:myc animated:YES completion:nil];
        
    }
    else{
        idofint ++;
        if (idofint < 10) {
            idofstr = [NSString stringWithFormat:@"0%d/24",idofint];
        }
        else
        {
            idofstr = [NSString stringWithFormat:@"%d/24",idofint];
            
        }
        imageName = [NSString stringWithFormat:@"%d.jpg",idofint];
        //将文字和图片显示出来
        self.imageID.text = idofstr;
        self.myImageView.image = [UIImage imageNamed:myImage];
    }
    
}
@end
